﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MDA
{
    /// <summary>
    /// MWinArgs
    /// 用于页面的模式窗口的参数。

    /// 包括：打开窗口的URL，对话框参数（dialogArguments）,页面属性参数（页面的呈现效果）。

    /// </summary>
    public class MWinArgs
    {
        /// <summary>
        /// 打开窗口的目标页面。

        /// </summary>
        public string Url = "";
        /// <summary>
        /// 传递到目标页面的对话框参数。

        /// </summary>
        public string DialogArguments = "";
        /// <summary>
        /// 用于控制页面的效果项。

        /// </summary>
        public NWinFeatures Features = new NWinFeatures();
        public MWinArgs()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
    }

    /// <summary>
    /// 用于页面的模式窗口的呈现效果参数。包括其长度、宽度等。

    /// </summary>
    public class NWinFeatures
    {
        /// <summary>
        /// 对话框高度。最小值为：100
        /// </summary>
        public int dialogHeight;
        /// <summary>
        /// 对话框左侧到屏幕左边的距离。


        /// </summary>
        public int dialogLeft;
        /// <summary>
        /// 对话框的上方到屏幕上边的距离。


        /// </summary>
        public int dialogTop;
        /// <summary>
        /// 对话框的高度。最小值为：100
        /// </summary>
        public int dialogWidth;
        /// <summary>
        /// 屏幕是否居中。

        /// </summary>
        public MWFeaturesValues center = MWFeaturesValues.yes;
        public string Center
        {
            get
            {
                if (center == MWFeaturesValues.one)
                    return "1";
                else if (center == MWFeaturesValues.zero)
                    return "0";
                else return center.ToString();
            }
            set
            {
                center = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        /// <summary>
        /// Specifies whether the dialog window is hidden when printing or using print preview.
        /// This feature is only available when a dialog box is opened from a trusted application. 
        /// The default is no.
        /// </summary>
        public MWFeaturesValues dialogHide = MWFeaturesValues.no;
        public string DialogHide
        {
            get
            {
                if (dialogHide == MWFeaturesValues.one)
                    return "1";
                else if (dialogHide == MWFeaturesValues.zero)
                    return "0";
                else return dialogHide.ToString();
            }
            set
            {
                dialogHide = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        /// <summary>
        /// Specifies the edge style of the dialog window. The default is raised.
        /// </summary>
        public FeaturesEdge edge = FeaturesEdge.raised;
        public string Edge
        {
            get
            {
                return edge.ToString();
            }
            set
            {
                edge = (FeaturesEdge)Enum.Parse(typeof(FeaturesEdge), value);
            }
        }
        /// <summary>
        /// Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes.
        /// </summary>
        public MWFeaturesValues help = MWFeaturesValues.yes;
        public string Help
        {
            get
            {
                if (help == MWFeaturesValues.one)
                    return "1";
                else if (help == MWFeaturesValues.zero)
                    return "0";
                else return help.ToString();
            }
            set
            {
                help = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        /// <summary>
        /// Specifies whether the dialog window has fixed dimensions. The default is no.
        /// </summary>
        public MWFeaturesValues resizable = MWFeaturesValues.no;
        public string Resizable
        {
            get
            {
                if (resizable == MWFeaturesValues.one)
                    return "1";
                else if (resizable == MWFeaturesValues.zero)
                    return "0";
                else return resizable.ToString();
            }
            set
            {
                resizable = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        /// <summary>
        /// Specifies whether the dialog window displays scrollbars. The default is yes.
        /// </summary>
        public MWFeaturesValues scroll = MWFeaturesValues.yes;
        public string Scroll
        {
            get
            {
                if (scroll == MWFeaturesValues.one)
                    return "1";
                else if (scroll == MWFeaturesValues.zero)
                    return "0";
                else return scroll.ToString();
            }
            set
            {
                scroll = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        /// <summary>
        /// Specifies whether the dialog window displays a status bar. 
        /// The default is yes for untrusted dialog windows and no for trusted dialog windows.
        /// </summary>
        public MWFeaturesValues status = MWFeaturesValues.no;
        public string Status
        {
            get
            {
                if (status == MWFeaturesValues.one)
                    return "1";
                else if (status == MWFeaturesValues.zero)
                    return "0";
                else return status.ToString();
            }
            set
            {
                status = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        /// <summary>
        /// Specifies whether the dialog window displays the border window chrome.
        /// This feature is only available when a dialog box is opened from a trusted application. The default is no.
        /// </summary>
        public MWFeaturesValues unadorned = MWFeaturesValues.no;
        public string Unadorned
        {
            get
            {
                if (unadorned == MWFeaturesValues.one)
                    return "1";
                else if (unadorned == MWFeaturesValues.zero)
                    return "0";
                else return unadorned.ToString();
            }
            set
            {
                unadorned = (MWFeaturesValues)Enum.Parse(typeof(MWFeaturesValues), value);
            }
        }
        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (dialogHeight != 0)
                sb.Append("dialogHeight:" + dialogHeight.ToString() + "px;");
            if (dialogLeft != 0)
                sb.Append("dialogLeft:" + dialogLeft.ToString() + "px;");
            if (dialogTop != 0)
                sb.Append("dialogTop:" + dialogTop.ToString() + "px;");
            if (dialogWidth != 0)
                sb.Append("dialogWidth:" + dialogWidth.ToString() + "px;");
            sb.Append("center:" + Center + ";");
            sb.Append("dialogHide:" + DialogHide + ";");
            sb.Append("edge:" + Edge + ";");
            sb.Append("help:" + Help + ";");
            sb.Append("resizable:" + Resizable + ";");
            sb.Append("scroll:" + Scroll + ";");
            sb.Append("status:" + Status + ";");
            sb.Append("unadorned:" + Unadorned + ";");
            return sb.ToString();
        }
    }

    /// <summary>
    /// Specifies the edge style of the dialog window. The default is raised.
    /// </summary>
    public enum FeaturesEdge
    {
        sunken,
        raised
    }
    /// <summary>
    /// 用于模式窗口的效果项
    /// </summary>
    public enum MWFeaturesValues
    {
        /// <summary>
        /// 启用相应的效果项。


        /// </summary>
        yes,
        /// <summary>
        /// 不启用相应的效果项。


        /// </summary>
        no,
        one,
        zero,
        on,
        off
    }
}